<?php 
    // 启动session
    session_start();
    require_once('mysql.php');
    $mail = $_POST['mail'];
    $password = $_POST['password'];

    //查询
    if($conn){
        //查询mail和password
	    $result = mysqli_query($conn,"SELECT * FROM users WHERE mail='$mail' AND password='$password'");
	    //遍历$result
	    $res = mysqli_fetch_array($result);
	    if(isset($res)){
		    // 获取插入行的id
		    $id = $res['id'];
		    // 记录登录的id
		    $_SESSION['uid'] = $id;
		    header('location:../html/project.php');
	    }else{
		    exit('错误：用户不存在。<a href="javascript:history.back(-1);">返回</a>');
	    }
    }
 ?>
